﻿using System;
using StructureMap;
using WholesaleOnline.Contract;
using WholesaleOnline.Controller;
using WholesaleOnline.DataContract.Messaging;
using WholesaleOnline.WebUI.Common;

namespace WholesaleOnline.WebUI.Pages
{
    public partial class BuyerHomePage : LoggedPage
    {
        private IBuyerHomePageService m_service = ObjectFactory.GetInstance<IBuyerHomePageService>();

        protected void Page_Load(object sender, EventArgs e)
        {
            GetBuyerResponse getBuyerResponse = m_service.GetBuyer(new GetBuyerRequest { LoginId = SessionCache.LognID });
            if (getBuyerResponse.Success)
                lblNickname.Text = getBuyerResponse.BuyerName;
            else
                Response.Redirect("LoginPage.aspx");

            GetAllSellersResponse getAllSellersResponse = m_service.GetAllSellers();
            rptSellerList.DataSource = getAllSellersResponse.Sellers;
            rptSellerList.DataBind();
        }
    }
}